layui.use(['jquery','upload','layer','laydate'],function () {
    var $ = layui.jquery;
    var upload = layui.upload;
    var laydate = layui.laydate;

    laydate.render({
        elem:"#startDate",
        type:"datetime",
        tigger:"click"
    });

    laydate.render({
        elem:"#expireDate",
        type:"datetime",
        tigger:"click"
    });

    /*上传头像*/
    var uploadInst = upload.render({
        elem: "#upload",
        url: "/newBanner/uploadFile",
        multiple: false,
        field: "file",
        size:"5M",
        accept: "images",
        before: function (obj) {
            $('#images').show();
        },
        done: function (res, index, upload) {
            var pricuteUrl = res.data.path;

            $('#imgAddress').attr("src","http://"+ pricuteUrl);
            $("#imgAddress").attr('style','width: 80px;height:80px;border:2px solid black');
        },
        error: function () {
            var demoText = $('#imgAddress');
            demoText.html('<span style="color: #ff1018;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
            demoText.find('.demo-reload').on('click', function () {
                uploadInst.upload();
            });
        }
    });
});